package com.smiier.skin;

import org.json.JSONArray;
import org.json.JSONObject;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
import cn.skinapp.R;

import com.evan.common.widget.ItemView;
import com.smiier.skin.constant.Constant;
import com.smiier.skin.ui.BasicActivity;
import com.smiier.skin.utils.CommonUtility;

public class PatientConditionInfo extends BasicActivity {
	private EditText edit_jibenbingqing;
	private ItemView wenti_fenlei_item;
	private EditText edit_bingzhengtuiduan_info;
	private ItemView patient_visiting_time;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_patient_condition_info);

		init();
		initDifferentView();

		initView();

	}

	private void initView() {
		edit_jibenbingqing = findViewById(R.id.edit_jibenbingqing,
				EditText.class);
		wenti_fenlei_item = findViewById(R.id.wenti_fenlei_item, ItemView.class);
		edit_bingzhengtuiduan_info = findViewById(
				R.id.edit_bingzhengtuiduan_info, EditText.class);
		patient_visiting_time = findViewById(R.id.patient_visiting_time,
				ItemView.class);

	}

	private void initDifferentView() {

		setNavTitle("患者病情");

		setNavLeftBtn("取消");

		setNavLeftBtnNoDrawable();

		setNavRightBtn("确认");

	}

	public void onClick(View view) {
		int key = view.getId();
		switch (key) {
		case R.id.wenti_fenlei_item:
			
			startActivityForResult(new Intent(activity,
					ZhengzhuangActivity.class), 0);

			break;

		case R.id.patient_visiting_time:

			break;

		case R.id.btn_left:
			// 取消
			onBackPressed();
			break;

		case R.id.text_right:

			checkAllInfo();

			break;
		default:
			break;
		}

	}

	private void checkAllInfo() {
		
		Log.i("testisempty", "value:"+(wenti_fenlei_item.getTextValueValue()));
		Log.i("testisempty", "value.boolean:"+(wenti_fenlei_item.getTextValueValue().toString().isEmpty()));
		
		if (edit_jibenbingqing.getText().toString().isEmpty()) {
			Toast.makeText(this, "请您描述患者的基本病情", Toast.LENGTH_SHORT).show();
		} else if (wenti_fenlei_item.getTextValueValue().toString().isEmpty()) {
			Toast.makeText(this, "请选择问题分类", Toast.LENGTH_SHORT).show();
		} else if (edit_bingzhengtuiduan_info.getText().toString().isEmpty()) {
			Toast.makeText(this, "请您输入病症作为对患者所提问题的病症推断", Toast.LENGTH_SHORT)
					.show();
		} else if (patient_visiting_time.getTextValueValue().toString().isEmpty()) {
			Toast.makeText(this, "请选择患者的实际就诊时间", Toast.LENGTH_SHORT).show();
		} else {

			/*
			 * 接口---- >推送服务器
			 */

		}

	}
	
	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		super.onActivityResult(requestCode, resultCode, data);
		if (!CommonUtility.isNull(data)) {
			String value = data.getStringExtra(Constant.IDENTITY_KEY);
			switch (resultCode) {
			case Constant.ACTIVITY_CHOOSE_ZHENGZHUANG:
				wenti_fenlei_item.setTextValueValue(value);
				break;
			}
		}
	}

}
